﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SmartEP.Presenter;

namespace SmartDesktop
{
    public partial class Step5View : MedicalHistoryBaseView, IStep5View
    {
        public Step5View(PatientCarePresenter presenter)
            : base(presenter)
        {
            InitializeComponent();
            this.Name = "Registration Step 5";
            MainForm.BarCaption.Text = this.Name;

            this.step = 5;
            this.GroupStep = GroupStepType.MedicalHistory;
        }

        #region Property
        public bool HaveAllergies
        {
            get
            {
                return rdHaveAllergiesYes.Checked;
            }
            set
            {
                rdHaveAllergiesYes.Checked = value;
            }
        }

        private IList<MedicineAllergy> _medicineAllergies;
        public IList<MedicineAllergy> MedicineAllergies
        {
            get
            {
                return _medicineAllergies;
            }
            set
            {
                for (int i = 0; i < dgMedicineAllergies.RowCount - 1; i++)
                {
                    MedicineAllergy medicineallergy = new MedicineAllergy();
                    medicineallergy.Medicine = dgMedicineAllergies.Rows[i].Cells[0].Value.ToString();
                    medicineallergy.AdverseReaction = dgMedicineAllergies.Rows[i].Cells[1].Value.ToString();
                    _medicineAllergies.Add(medicineallergy);
                }
            }
        }

        private IList<Medication> _medications;
        public IList<Medication> Medications
        {
            get
            {
                return _medications;
            }
            set
            {
                for (int i = 0; i < dgCurrentMedications.RowCount - 1; i++)
                {
                    Medication medications = new Medication();
                    medications.Medicine = dgCurrentMedications.Rows[i].Cells[0].Value.ToString();
                    medications.Dosage = dgCurrentMedications.Rows[i].Cells[1].Value.ToString();
                    medications.Frequency = dgCurrentMedications.Rows[i].Cells[2].Value.ToString();
                    _medications.Add(medications);
                }
            }
        }

        private IList<Surgery> _majorsurgeries;
        public IList<Surgery> MajorSurgeries
        {
            get
            {
                return _majorsurgeries;
            }
            set
            {
                for (int i = 0; i < dgCurrentMedications.RowCount - 1; i++)
                {
                    Surgery majorsurgeriestions = new Surgery();
                    majorsurgeriestions.Description = dgMajorSurgeries.Rows[i].Cells[0].Value.ToString();
                    majorsurgeriestions.SurgeryDate = Convert.ToDateTime(dgMajorSurgeries.Rows[i].Cells[1].Value);
                    _majorsurgeries.Add(majorsurgeriestions);
                }
            }
        }

        public bool IsPregnantOrNursing
        {
            get
            {
                return rdPregnantOrNursingYes.Checked;
            }
            set
            {
                rdPregnantOrNursingYes.Checked = value;
            }
        }

        public bool WearGlasses
        {
            get
            {
                return rdWearGlassesYes.Checked;
            }
            set
            {
                rdWearGlassesYes.Checked = value;
            }
        }

        public bool WearContacts
        {
            get
            {
                return rdWearContactsYes.Checked;
            }
            set
            {
                rdWearContactsYes.Checked = value;
            }
        }

        public string HowOldThePresentContacts
        {
            get
            {
                return txtPresentContacts.Text;
            }
            set
            {
                txtPresentContacts.Text = value;
            }
        }
        bool[] _currentContactsType = new bool[3];
        public bool[] CurrentContactsType
        {
            get
            {
                return _currentContactsType;
            }
            set
            {
                if (chkSoft.Checked)
                    _currentContactsType[0] = true;
                if (chkGesPem.Checked)
                    _currentContactsType[1] = true;
                if (chkExtendedWear.Checked)
                    _currentContactsType[2] = true;
            }
        }
        #endregion

        private void btnContinue_Click(object sender, EventArgs e)
        {
            this.presenter.DisplayNextStep(this.step);
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.presenter.BackToPreviousStep(this.step);
        }

    }
}
